#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define y1 y_alpha_1

using namespace std;

using ll = long long;
using db = double;
using vec = vector<int>;
using pii = pair<int,int>;

int read() {
	int x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-',ch = getchar();
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48),ch = getchar();
	return f ? -x : x;
}

const int N = 3e5+10;

int H,W,M,n,cnt;
int stk1[N],stk2[N],t1,t2,up[N],dn[N],ans;

namespace st {	
	int tg[N << 2],mx[N << 2];
	void add(int x,int v) {tg[x] += v; mx[x] += v;}
	void pushd(int x) {if(tg[x]) add(x << 1,tg[x]),add(x << 1 | 1,tg[x]),tg[x] = 0;}
	void upd(int xl,int xr,int v,int o = 1,int l = 1,int r = cnt) {
		if(xl == l && xr == r) return add(o,v); int mid = l + r >> 1; pushd(o);
		if(xr <= mid) upd(xl,xr,v,o << 1,l,mid); else if(xl > mid) upd(xl,xr,v,o << 1 | 1,mid + 1,r);
		else upd(xl,mid,v,o << 1,l,mid) , upd(mid + 1,xr,v,o << 1 | 1,mid + 1,r); mx[o] = max(mx[o << 1],mx[o << 1 | 1]);
	}
	void upda(int xl,int xr,int v) {if(xl > xr) return ; upd(xl,xr,v);}
	int qmax(){return mx[1];}
	void clear(){memset(tg,0,(cnt + 2) << 4); memset(mx,0,(cnt + 2) << 4);}
}

struct node{
	int x,y;
	friend bool operator < (node a,node b){return a.x == b.x ? a.y < b.y : a.x < b.x;}
}a[N];
	
void solve() {
	sort(a + 1,a + cnt + 1); t1 = t2 = 0; st :: clear();
	for(int i = 1;i < cnt;i++) {
		int pos = i;
		if(a[i].y <= M) {
			while(t1 && dn[stk1[t1]] <= a[i].y) st :: upda(stk1[t1],pos - 1,dn[stk1[t1]] - a[i].y) , pos = stk1[t1], t1--;
			stk1[++t1] = pos; dn[pos] = a[i].y;
		} else {
			while(t2 && up[stk2[t2]] >= a[i].y) st :: upda(stk2[t2],pos - 1,a[i].y - up[stk2[t2]]) , pos = stk2[t2], t2--;
			stk2[++t2] = pos; up[pos] = a[i].y;
		}
		stk1[++t1] = i; dn[i] = 0; stk2[++t2] = i; up[i] = H; st :: upda(i,i,H - a[i].x);
		ans = max(ans,st :: qmax() + a[i + 1].x);
	}
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	W = in,H = in,n = in; for(int i = 1;i <= n;i++) a[i].x = in,a[i].y = in; cnt = n + 2; a[n + 2] = (node){W,H};
	M = H >> 1; solve(); swap(W,H); for(int i = 1;i <= cnt;i++) swap(a[i].x,a[i].y); M = H >> 1; solve();
	printf("%d\n",ans * 2);
	return 0;
}
